// 封装 axios 请求模块
import axios from 'axios'
import store from '@/store'

const instance = axios.create({
  baseURL: 'http://toutiao-app.itheima.net'
})
// 请求拦截器
instance.interceptors.request.use(config => {
  if (store.state.user) {
    config.headers.Authorization = `Bearer ${store.state.user.token}`
  }
  return config
})

export default instance
